//
//  ALMoreMasterViewController.m
//  TestAfn2
//
//  Created by XuJingJing on 16/7/24.
//  Copyright © 2016年 xujingjing. All rights reserved.
//

#import "ALMoreMasterViewController.h"

@interface ALMoreMasterViewController ()
@property (weak, nonatomic) IBOutlet UIButton *masterFirstShow;

@property (weak, nonatomic) IBOutlet UISearchBar *searchBar;
@end

@implementation ALMoreMasterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setClearSeachBar];
}
- (void)setClearSeachBar{

    UIImage* searchBarBg = [self GetImageWithColor:[UIColor clearColor] andHeight:32.0f];
    //设置背景图片
    [_searchBar setBackgroundImage:searchBarBg];
    //设置背景色
    [_searchBar setBackgroundColor:[UIColor clearColor]];
    //设置文本框背景
    [_searchBar setSearchFieldBackgroundImage:searchBarBg forState:UIControlStateNormal];
    [self setOtherDefineSearchBarProperty];
}
-(void)setOtherDefineSearchBarProperty{
    //1、设置字体颜色、默认字体颜色等
    
    UITextField *searchField = [_searchBar valueForKey:@"_searchField"];
    searchField.textColor = [UIColor whiteColor];
    [searchField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
  //  2、修改放大镜
    UIImage *image = [UIImage imageNamed:@"cl_tab2_gray"];
    UIImageView *iconView = [[UIImageView alloc] initWithImage:image];
    iconView.frame = CGRectMake(0, 0, image.size.width , image.size.height);
    searchField.leftView = iconView;

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)masterFirstShowBtnPressed:(id)sender {
    
    
}

- (UIImage*) GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height
{
    CGRect r= CGRectMake(0.0f, 0.0f, 1.0f, height);
    UIGraphicsBeginImageContext(r.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, r);
    
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return img;
}
@end
